package com.nearby.demand.interactor;

import android.graphics.Bitmap;

import com.request.ok.http.OkHttpUtils;
import com.request.ok.http.callback.BitmapCallback;
import com.squareup.okhttp.Request;

/**
 * Created by IME on 2016/home_1/10.
 */
public class SplashInteractorImpl implements SplashInteractor {
    @Override
    public void requestSplashImage(final OnSplashListener listener) {
        OkHttpUtils
                .get()//
                .url("http://f5.topitme.com/5/83/d1/1103837923944d1835l.jpg")//
                .tag(this)//
                .build()//
                .connTimeOut(20000)
                .readTimeOut(20000)
                .writeTimeOut(20000)
                .execute(new BitmapCallback() {
                    @Override
                    public void onError(Request request, Exception e) {
                        listener.onError();
                    }

                    @Override
                    public void onResponse(Bitmap bitmap) {
                        listener.onSuccess(bitmap);
                    }
                });

    }

}
